package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.*;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Salary {
    private Long id;
    //  工资金额
    private Long money;
    //  年份
    private Integer year;
    //  月份
    private Integer month;
    //  员工对象
    private Employee employee;
    //  工资发放方式
    private SystemDictionaryItem payout;

    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("money", money);
        map.put("year", year);
        map.put("month", month);
        if (employee != null) {
            map.put("employeeId", employee.getId());
        }
        if (payout != null) {
            map.put("payoutId", payout.getId());
        }
        return JSON.toJSONString(map);
    }
}